/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agtranscontinental.sisref.model;

import com.agtranscontinental.sisref.dto.RevisionDto;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author ericson
 */
@Entity
@Table(name = "revision")
@NamedQueries({
    @NamedQuery(name = "Revision.findAll", query = "SELECT r FROM Revision r"),
    @NamedQuery(name = "Revision.findById", query = "SELECT r FROM Revision r WHERE r.id = :id"),
    @NamedQuery(name = "Revision.findByIsScio", query = "SELECT r FROM Revision r WHERE r.isScio = :isScio"),
    @NamedQuery(name = "Revision.findByCtdad", query = "SELECT r FROM Revision r WHERE r.ctdad = :ctdad"),
    @NamedQuery(name = "Revision.findByIsBdaRddo", query = "SELECT r FROM Revision r WHERE r.isBdaRddo = :isBdaRddo"),
    @NamedQuery(name = "Revision.findByIsHbro", query = "SELECT r FROM Revision r WHERE r.isHbro = :isHbro"),
    @NamedQuery(name = "Revision.findByIsPredLtral", query = "SELECT r FROM Revision r WHERE r.isPredLtral = :isPredLtral"),
    @NamedQuery(name = "Revision.findByIsTlon", query = "SELECT r FROM Revision r WHERE r.isTlon = :isTlon"),
    @NamedQuery(name = "Revision.findByIsItrio", query = "SELECT r FROM Revision r WHERE r.isItrio = :isItrio"),
    @NamedQuery(name = "Revision.findByIsDnio", query = "SELECT r FROM Revision r WHERE r.isDnio = :isDnio"),
    @NamedQuery(name = "Revision.findByAcho", query = "SELECT r FROM Revision r WHERE r.acho = :acho"),
    @NamedQuery(name = "Revision.findByLgo", query = "SELECT r FROM Revision r WHERE r.lgo = :lgo"),
    @NamedQuery(name = "Revision.findByPfddad", query = "SELECT r FROM Revision r WHERE r.pfddad = :pfddad"),
    @NamedQuery(name = "Revision.findByIdOden", query = "SELECT r FROM Revision r WHERE r.idOden = :idOden")})
public class Revision implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;
    @Column(name = "is_scio")
    private Boolean isScio;
    @Size(max = 160)
    @Column(name = "otro_dnio")
    private String otroDnio;
    @Column(name = "ctdad")
    private Integer ctdad;
    @Column(name = "is_bda_rddo")
    private Boolean isBdaRddo;
    @Column(name = "is_hbro")
    private Boolean isHbro;
    @Column(name = "is_pred_ltral")
    private Boolean isPredLtral;
    @Column(name = "is_tlon")
    private Boolean isTlon;
    @Column(name = "is_itrio")
    private Boolean isItrio;
    @Column(name = "is_dnio")
    private Boolean isDnio;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "acho")
    private Double acho;
    @Column(name = "lgo")
    private Double lgo;
    @Column(name = "pfddad")
    private Double pfddad;
    @Column(name = "id_oden")
    private Integer idOden;
    @JoinColumn(name = "id_srie", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Serie serie;
    @JoinColumn(name = "id_dnio", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Danio danio;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "revision")
    private List<Foto> fotoList;

    public Revision() {
    }

    public Revision(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Boolean getIsScio() {
        return isScio;
    }

    public void setIsScio(Boolean isScio) {
        this.isScio = isScio;
    }


    public Integer getCtdad() {
        return ctdad;
    }

    public void setCtdad(Integer ctdad) {
        this.ctdad = ctdad;
    }

    public Boolean getIsBdaRddo() {
        return isBdaRddo;
    }

    public void setIsBdaRddo(Boolean isBdaRddo) {
        this.isBdaRddo = isBdaRddo;
    }

    public Boolean getIsHbro() {
        return isHbro;
    }

    public void setIsHbro(Boolean isHbro) {
        this.isHbro = isHbro;
    }

    public Boolean getIsPredLtral() {
        return isPredLtral;
    }

    public void setIsPredLtral(Boolean isPredLtral) {
        this.isPredLtral = isPredLtral;
    }

    public Boolean getIsTlon() {
        return isTlon;
    }

    public void setIsTlon(Boolean isTlon) {
        this.isTlon = isTlon;
    }

    public Boolean getIsItrio() {
        return isItrio;
    }

    public void setIsItrio(Boolean isItrio) {
        this.isItrio = isItrio;
    }

    public Boolean getIsDnio() {
        return isDnio;
    }

    public void setIsDnio(Boolean isDnio) {
        this.isDnio = isDnio;
    }

    public Double getAcho() {
        return acho;
    }

    public void setAcho(Double acho) {
        this.acho = acho;
    }

    public Double getLgo() {
        return lgo;
    }

    public void setLgo(Double lgo) {
        this.lgo = lgo;
    }

    public Double getPfddad() {
        return pfddad;
    }

    public void setPfddad(Double pfddad) {
        this.pfddad = pfddad;
    }

    public Integer getIdOden() {
        return idOden;
    }

    public void setIdOden(Integer idOden) {
        this.idOden = idOden;
    }

    public Serie getSerie() {
        return serie;
    }

    public void setSerie(Serie serie) {
        this.serie = serie;
    }

    public Danio getDanio() {
        return danio;
    }

    public void setDanio(Danio danio) {
        this.danio = danio;
    }

    public List<Foto> getFotoList() {
        return fotoList;
    }

    public void setFotoList(List<Foto> fotoList) {
        this.fotoList = fotoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Revision)) {
            return false;
        }
        Revision other = (Revision) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agtranconstinental.sisref.Revision[ id=" + id + " ]";
    }

    public static final Revision parseToRevision(RevisionDto revisionDto) {
        if (revisionDto != null) {
            Revision rev = new Revision();
            rev.setId(revisionDto.getId());
            rev.setAcho(revisionDto.getAcho());
            rev.setCtdad(revisionDto.getCtdad());
            Danio danio = new Danio();
            danio.setId(revisionDto.getIdDnio());
            rev.setDanio(danio);
            rev.setIdOden(revisionDto.getIdOden());
            rev.setIsBdaRddo(revisionDto.getIsBdaRddo());
            rev.setIsDnio(revisionDto.getIsDnio());
            rev.setIsHbro(revisionDto.getIsHbro());
            rev.setIsItrio(revisionDto.getIsItrio());
            rev.setIsPredLtral(revisionDto.getIsPredLtral());
            rev.setIsScio(revisionDto.getIsScio());
            rev.setIsTlon(revisionDto.getIsTlon());
            rev.setLgo(revisionDto.getLgo());
            rev.setPfddad(revisionDto.getPfddad());
            Serie serie = new Serie();
            serie.setId(revisionDto.getIdSrie());
            rev.setSerie(serie);
            rev.setOtroDnio(revisionDto.getOtroDnio());
        }

        return null;
    }

    /**
     * @return the otroDnio
     */
    public String getOtroDnio() {
        return otroDnio;
    }

    /**
     * @param otroDnio the otroDnio to set
     */
    public void setOtroDnio(String otroDnio) {
        this.otroDnio = otroDnio;
    }
}
